Repository navigation
test(demo): make the sibling-failure test wait for its third change before failing - #1181
sbalabanov wants to merge 1 commit into
Conversation
…efore failing TestSiblingFailureDoesNotCancelInFlightLand hung until the Bazel timeout in about 1 of 10 runs under the race detector. Change 2's Land blocks until change 3's readiness hook closes siblingsCancelled, which happens only after the gate is cancelled. Change 1's hook cancels the gate by failing as soon as Land starts. If change 1 failed before change 3 reached Readiness.Wait, the runner skipped change 3 because its gate was already cancelled, so nothing ever closed siblingsCancelled and Land blocked forever. The production code is correct; the test did not enforce the order it relies on. Change 1's hook now also waits for a thirdWaiting channel that change 3 closes on entering Wait, so the gate cannot cancel before change 3 is inside Wait. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
sbalabanov
left a comment
There was a problem hiding this comment.
[flaky-1-f1-reviewer] nit: PR description only. The Test Plan line "The pre-fix hang demonstration (optional command in the spec) was not run." refers to a document that readers of this public repository cannot see. The Summary's "about 1 of 10 runs" is a pre-fix rate that this PR did not measure. Consider replacing that bullet with a self-contained repro that says where the rate comes from, for example: "Repro (not run here): the targeted stress command above, run on the parent commit, hangs until the test timeout; an earlier investigation saw the whole package hang in about 1 of 10 race runs." That also gives the description the repro step a bug fix should have.
Verdict: satisfied with head b119828; the nit above is optional. Checked against run.go:
- Ordering: nothing can cancel the gate before change 3 enters
Wait. Change 1 is parked onthirdWaitingand change 2 onsiblingsCancelled, andOpen/Waitsucceed for changes 2 and 3. So change 3 always passes the gate checks atrun.go:221,:225and:259, in every schedule, including GOMAXPROCS=1. - No double close: each
closeruns once per iteration. There is oneforEachChange, oneWaitper change, and each-test.countiteration makes fresh channels. - Coverage kept:
Landis in flight before change 1 fails and returns only after the gate is cancelled. A regression that ranLandon the gate would fail onassert.NoError(t, landErr)instead of hanging. - Rules and scope: no sleep, no timeout, one hazard-comment line, only
run_test.go. - Alternatives: none smaller. Having
Landwait on a gate captured from change 1's hook would make change 3 unnecessary, but it is a larger rewrite.
|
[flaky-1-f1-implementer] fixed in PR body: replaced the spec reference in the Test Plan with a self-contained, not-run-here repro command and credited the failure rate to the flakiness investigation. |
TLDR: A demo test could hang forever because two goroutines raced; the test now makes one wait for the other so the hang cannot happen.
Summary
TestSiblingFailureDoesNotCancelInFlightLandhung until the Bazel timeout under the race detector (about 1 in 10 runs, measured during the flakiness investigation).Landblocks until change 3's readiness hook closessiblingsCancelled, which only happens after the gate is cancelled. Change 1's hook cancels the gate by failing as soon asLandstarts. If change 1 failed before change 3 reachedReadiness.Wait, the runner skipped change 3 (its gate was already cancelled), nothing closedsiblingsCancelled, andLandblocked forever. The production code is correct; the test did not enforce the order it relies on.thirdWaitingchannel that change 3 closes on enteringWait, so the gate cannot cancel before change 3 is insideWait. Test-only, no timeouts added.Test Plan
Run locally from the repo root:
./tool/bazel test //service/submitqueue/demo:go_default_test- PASSED./tool/bazel test //service/submitqueue/demo:go_default_test --@rules_go//go/config:race --build_tests_only --test_arg=-test.run='^TestSiblingFailureDoesNotCancelInFlightLand$' --test_arg=-test.cpu=1 --test_arg=-test.count=300 --runs_per_test=10 --nocache_test_results- 10/10 PASSED./tool/bazel test //service/submitqueue/demo:go_default_test --@rules_go//go/config:race --build_tests_only --runs_per_test=100 --runs_per_test_detects_flakes --nocache_test_results- 100/100 PASSED (run with--local_test_jobs=8instead of 32 on a shared host)make fmt lint check-gazelle check-tidy- passed./tool/bazel test //service/submitqueue/demo:go_default_test --@rules_go//go/config:race --build_tests_only --test_arg=-test.run='^TestSiblingFailureDoesNotCancelInFlightLand$' --test_arg=-test.cpu=1 --test_arg=-test.count=300 --runs_per_test=5 --nocache_test_results --test_timeout=120; hung runs hit the 120s timeout (the timeout flag only bounds the demonstration and is not part of the test).🤖 Generated with Claude Code